<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="file" name="file" id="file" />
    <script>
      const file = document.getElementById("file");
      file.addEventListener("change", (e) => {
        var data2 = new FormData();
        data2.append("pic", e.target.files[0]);

        var xhr = new XMLHttpRequest();
        xhr.withCredentials = true;

        xhr.addEventListener("readystatechange", function () {
          if (this.readyState === 4) {
            console.log(this.responseText);
          }
        });

        xhr.open("POST", "https://81.68.79.49:443/upfile");

        xhr.send(data2);

        // console.log(e.target.files[0]);

        // var formdata = new FormData();
        // formdata.append(
        //   "pic",
        //   e.target.files[0]
        // );

        // var requestOptions = {
        //   method: "POST",
        //   body: formdata,
        //   redirect: "follow",
        // };

        // fetch("https://81.68.79.49:443/upfile", requestOptions)
        //   .then((response) => response.text())
        //   .then((result) => console.log(result))
        //   .catch((error) => console.log("error", error));
      });
    </script>
  </body>
</html>
